//添加论坛问题回答评论且更新评论数
exports.au_forum_content_answer_comment = function (req, res) {

    var bodyParams = req.routeInfo.bodyParams;
    //最终结果
    var resultData = {};

    var forumContentAnswerData = 0;
    //任务流创建
    async.waterfall([
            //1.添加回答评论记录记录
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.addContentAnserComment,
                        method: 'POST',
                        data: {
                            fcac_fcaid: bodyParams.fcac_fcaid,
                            fcac_content: bodyParams.fcac_content,
                            fcac_uid: bodyParams.fcac_uid,
                            fcac_is_reply: bodyParams.fcac_is_reply,
                            fcac_reply_uid: bodyParams.fcac_reply_uid
                        }
                    },
                    function (err, data) {
                        // //console.log(data);
                        //判断是否有错误信息
                        if (err) {
                            return RES.response(res, false, data);
                        }
                        resultData.addData = data.data;
                        cb();
                    }
                );
            },
            //2.查询回答评论数
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.searchContentAnswer + "/fca_id/" + bodyParams.fcac_fcaid,
                        method: 'POST',
                        data: {
                            fields: ["fca_id", "fca_comment_count"].join(",")
                        }
                    },
                    function (err, data) {
                        //console.log(data);
                        //判断是否有错误信息
                        if (err) {
                            return RES.response(res, false, data);
                        }

                        forumContentAnswerData = data.data;
                        cb();
                    }
                );

            },
            //3.回答评论数更新
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.updateContentAnswer,
                        method: 'POST',
                        data: {
                            fca_id: bodyParams.fcac_fcaid,
                            fca_comment_count: parseInt(forumContentAnswerData[0].fca_comment_count) + 1
                        }
                    },
                    function (err, data) {
                        //判断是否有错误信息
                        if (err) {
                            return RES.response(res, false, data);
                        }

                        resultData.updateData = data;
                        cb();
                    }
                );

            },
        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

};
